package 公司真题.美团;

import java.util.Scanner;

public class _神秘的苹果树 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNextLine()) {
            int nodeCount = Integer.parseInt(sc.nextLine()) - 1;
            StringBuilder sb = new StringBuilder();
            while (nodeCount > 0) {
                if (nodeCount == 1) {
                    sb.append(sc.nextLine().trim());
                } else {
                    sb.append(sc.nextLine().trim()).append(",");
                }
                nodeCount--;
            }
            TreeNode root = buildTree(sb.toString());
            String everyNodeColor = sc.nextLine().trim();
            colorTree(root, everyNodeColor);
            int jiexialai_needRequestCount = Integer.parseInt(sc.nextLine());
            while (jiexialai_needRequestCount > 0) {
                int curRequestNode = Integer.parseInt(sc.nextLine());
                int whatColor = toGetMaxApplesWithColor(curRequestNode);
                System.out.println(whatColor);
                jiexialai_needRequestCount--;
            }
        }
    }

    private static int toGetMaxApplesWithColor(int curRequestNode) {
        return 0;
    }

    private static void colorTree(TreeNode root, String everyNodeColor) {

    }

    private static TreeNode buildTree(String toString) {
        return null;
    }
}
class TreeNode {

}
